package com.xjrsoft.module.customerTwo.vue输出区域.dfa.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.dto.Table09218Dto;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.dto.SaveTable09218FormDataDto;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.vo.Table09218Vo;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.vo.Table09218ListVo;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.dto.Table09218ListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.entity.Table09218;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.vo.Table09218Vo;
import com.xjrsoft.module.customerTwo.vue输出区域.dfa.service.ITable09218Service;

/**
 *  控制器
 *
 * @author dadasfdas
 * @since 2023-12-07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dfa")
@Api(value = "测试111", tags = "测试111接口")
public class Table09218Controller {


	private final ITable09218Service table09218Service;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入table09218")
	@SaCheckPermission(value = {"dfa:view", "dfa:modify"}, mode = SaMode.OR)
	public Response<Table09218Vo> getFormData(@PathVariable String id) {
		// 主表数据
		Table09218 table09218 = table09218Service.getById(id);
		Table09218Vo table09218Vo = BeanUtil.copy(table09218, Table09218Vo.class);
		return Response.ok(table09218Vo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入table09218")
		public Response<PageOutput<Table09218ListVo>> getPageList(Table09218ListDto listDto) {
		IPage<Table09218> page = table09218Service.getPageList(listDto);
		List<Table09218ListVo> records = BeanUtil.copyList(page.getRecords(), Table09218ListVo.class);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入table09218")
	@SaCheckPermission("dfa:add")
	public Response save(@RequestBody SaveTable09218FormDataDto formDto) {
		Table09218Dto table09218Dto = formDto.getTable09218Dto();
		Table09218 table09218 = BeanUtil.copy(table09218Dto, Table09218.class);
		boolean isSuccess = table09218Service.addTable09218(table09218);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入table09218")
	@SaCheckPermission("dfa:modify")
	public Response update(@PathVariable String id, @RequestBody SaveTable09218FormDataDto formDto) {
		Table09218Dto table09218Dto = formDto.getTable09218Dto();
		Table09218 table09218 = BeanUtil.copy(table09218Dto, Table09218.class);
		return Response.status(table09218Service.updateTable09218(id, table09218));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	@SaCheckPermission(value = {"dfa:batchDelete", "dfa:delete"}, mode = SaMode.OR)
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(table09218Service.delete(ids));
	}


}
